<?php
/**
 * Created by PhpStorm.
 * User: WUHENG
 * Date: 2022/9/29
 * Time: 10:00
 */

namespace app\conmon\validate;


use think\Validate;

class admValidate extends Validate
{
    protected $rule = [
        'admPhone' => 'require|checkPhone',
        'admPass' => 'require|min:6'
    ];

    protected $message = [
        'admPhone.require' => '请输入手机号',
        'admPhone.checkPhone' => '请输入正确的手机号',
        'admPass.require' => '密码必填',
        'admPass.min' => '密码最少6位'
    ];

    protected function checkPhone($value){
        $rule = '/^0?(13|14|15|17|18)[0-9]{9}$/';
        $result = preg_match($rule, $value);
        if ($result) {
            return true;
        } else {
            return false;
        }
    }
}